package com.pay.bean;

import com.pay.util.PayConstant;


public class GlobalData {
    public static String URL_API = "http://pay.payone.top/pay/";
    public static final String APP_ID = "28C85D0FB0E5475B9498C86971FC8515";
    public static final String API_VER = "1.0";
    public static final String PAY_TYPE = "alipay";
    public static final String SCENE = "wap";
    public static final String TERMINAL = "android";
    public static final String FMT = "json";
    public static final String CHARSET = "utf-8";
    public static final String TYPE = "md5";
    public static final String NOTE_URL = "http://47.94.249.1:8080/AliWap/noteUrl.jsp";
    public static final String RTN_URL = "http://47.94.249.1:8080/AliWap/rtnUrl.jsp";
    //这个秘钥要改成自己的,APP_ID,NOTE_URL,RTN_URL 都要改成自己的,这个是测试账号使用的秘钥
    public static final String SECRET = "CAACC818BCCEC16457C2514F89196C33FAA683CFB4694912829914E83849790F";
    public static final String STATE_SUCCESS = "success";
    public static final String STATE_FAILED = "failed";
    public static final String STATE_EMPTY_JSON = "空的json数据";
    public static final String STATE_SIGN_NOT_PASSED = "签名不通过";
    public static final String TEST_DATA = "{\"appId\":\"28C85D0FB0E5475B9498C86971FC8515\",\"apiVer\":\"1.0\",\"payType\":\"alipay\",\"scene\":\"wap\",\"terminal\":\"android\",\"fmt\":\"json\",\"charset\":\"utf-8\",\"sgnType\":\"md5\",\"merchOrdrNo\":\"20171218093615378129\",\"usrPayAmt\":\"1\",\"platformOrdrNo\":\"20171218093615653409\",\"state\":\"success\",\"timeStamp\":\"2017-12-18 11:36:12\",\"usrName\":\"zhangsan\",\"extParm\":\"fujiacanshu\",\"sgn\":\"e23d55452c5925e0279fe2ca68ad3b61\"}";

    /**
     * 组成post数据
     *
     * @param payBean
     * @return
     */
    public static String composePostStr(PayBean payBean) {
        String srcStr = "{\"" + PayConstant.KEY_APPID + "\":\"" + payBean.getAppId() + "\",\"" + PayConstant.KEY_API_VER + "\":\"" + payBean.getApiVer()
                + "\",\"" + PayConstant.KEY_PAY_TYPE + "\":\"" + payBean.getPayType() + "\",\"" + PayConstant.KEY_SCENE + "\":\"" + payBean.getScene()
                + "\",\"" + PayConstant.KEY_TERMINAL + "\":\"" + payBean.getTerminal() + "\",\"" + PayConstant.KEY_FMT + "\":\"" + payBean.getFmt()
                + "\",\"" + PayConstant.KEY_CHARSET + "\":\"" + payBean.getCharset() + "\",\"" + PayConstant.KEY_SGN_TYPE + "\":\"" + payBean.getSgnType()
                + "\",\"" + PayConstant.KEY_MERCH_ORDR_NO + "\":\"" + payBean.getMerchOrdrNo() + "\",\"" + PayConstant.KEY_TOT_ORDR_AMT + "\":\"" + payBean.getTotOrdrAmt()
                + "\",\"" + PayConstant.KEY_NOTE_URL + "\":\"" + payBean.getNoteUrl() + "\",\"" + PayConstant.KEY_RTN_URL + "\":\"" + payBean.getRtnUrl()
                + "\",\"" + PayConstant.KEY_TIME_STAMP + "\":\"" + payBean.getTimeStamp() + "\",\"" + PayConstant.KEY_USR_NAME + "\":\"" + payBean.getUsrName()
                + "\",\"" + PayConstant.KEY_EXT_PARM + "\":\"" + payBean.getExtParm() + "\",\"" + PayConstant.KEY_SGN + "\":\"" + payBean.getSgn() + "\"}";
        return srcStr;
    }

    /**
     * @param payBean 原始数据,请求支付的数据
     * @return MD5前的原始数据
     */
    public static String composePayJsonStr(PayBean payBean) {
        String srcStr = "{\"" + PayConstant.KEY_APPID + "\":\"" + payBean.getAppId() + "\",\"" + PayConstant.KEY_API_VER + "\":\"" + payBean.getApiVer()
                + "\",\"" + PayConstant.KEY_PAY_TYPE + "\":\"" + payBean.getPayType() + "\",\"" + PayConstant.KEY_SCENE + "\":\"" + payBean.getScene()
                + "\",\"" + PayConstant.KEY_TERMINAL + "\":\"" + payBean.getTerminal() + "\",\"" + PayConstant.KEY_FMT + "\":\"" + payBean.getFmt()
                + "\",\"" + PayConstant.KEY_CHARSET + "\":\"" + payBean.getCharset() + "\",\"" + PayConstant.KEY_SGN_TYPE + "\":\"" + payBean.getSgnType()
                + "\",\"" + PayConstant.KEY_MERCH_ORDR_NO + "\":\"" + payBean.getMerchOrdrNo() + "\",\"" + PayConstant.KEY_TOT_ORDR_AMT + "\":\"" + payBean.getTotOrdrAmt()
                + "\",\"" + PayConstant.KEY_NOTE_URL + "\":\"" + payBean.getNoteUrl() + "\",\"" + PayConstant.KEY_RTN_URL + "\":\"" + payBean.getRtnUrl()
                + "\",\"" + PayConstant.KEY_TIME_STAMP + "\":\"" + payBean.getTimeStamp() + "\",\"" + PayConstant.KEY_USR_NAME + "\":\"" + payBean.getUsrName()
                + "\",\"" + PayConstant.KEY_EXT_PARM + "\":\"" + payBean.getExtParm() + "\",\"" + PayConstant.KEY_SECRET + "\":\"" + SECRET + "\"}";
        return srcStr;
    }

    /**
     * @param payResultBean 支付结果的数据
     * @return MD5前的原始数据
     */
    public static String composePayResultJsonStr(PayResultBean payResultBean) {
        String srcStr = "{\"" + PayConstant.KEY_APPID + "\":\"" + payResultBean.getAppId() + "\",\"" + PayConstant.KEY_API_VER + "\":\"" + payResultBean.getApiVer()
                + "\",\"" + PayConstant.KEY_PAY_TYPE + "\":\"" + payResultBean.getPayType() + "\",\"" + PayConstant.KEY_SCENE + "\":\"" + payResultBean.getScene()
                + "\",\"" + PayConstant.KEY_TERMINAL + "\":\"" + payResultBean.getTerminal() + "\",\"" + PayConstant.KEY_FMT + "\":\"" + payResultBean.getFmt()
                + "\",\"" + PayConstant.KEY_CHARSET + "\":\"" + payResultBean.getCharset() + "\",\"" + PayConstant.KEY_SGN_TYPE + "\":\"" + payResultBean.getSgnType()
                + "\",\"" + PayConstant.KEY_MERCH_ORDR_NO + "\":\"" + payResultBean.getMerchOrdrNo() + "\",\"" + PayConstant.KEY_USR_PAY_AMT + "\":\"" + payResultBean.getUsrPayAmt()
                + "\",\"" + PayConstant.KEY_PLATFORM_ORDRNO + "\":\"" + payResultBean.getPlatformOrdrNo() + "\",\"" + PayConstant.KEY_STATE + "\":\"" + payResultBean.getState()
                + "\",\"" + PayConstant.KEY_TIME_STAMP + "\":\"" + payResultBean.getTimeStamp() + "\",\"" + PayConstant.KEY_USR_NAME + "\":\"" + payResultBean.getUsrName()
                + "\",\"" + PayConstant.KEY_EXT_PARM + "\":\"" + payResultBean.getExtParm() + "\",\"" + PayConstant.KEY_SECRET + "\":\"" + SECRET + "\"}";
        return srcStr;
    }
}
